
<?php
 
	function smarty_block_ship_licenses($params, $content, &$smarty, &$repeat) {

		global $db, $config;

		$l = count($smarty->_tag_stack);
		if(empty($params['name'])) $params['name'] = "ship_licenses";
        
		if(empty($smarty->blockvars[$l])) 
		{
			if(isset($params['ship_id']) && 0 < $params['ship_id'])
			{
                $sqlstr = "select * from {$config->db_prefix}ship_license where ship_id=".$params['ship_id'];
                $limit = empty($params['limit'])?9999:$params['limit'];
                $page = empty($params['page'])?1:$params['page'];
                $pager = new pager($limit, $page);
                $smarty->blockvars[$l] = $pager->execute($db, $sqlstr);

                if(!$smarty->blockvars[$l]) return $repeat = false;
                if(!empty($params['pager'])) $smarty->assign($params['pager'], $pager);
            }
		}
        
		if(list($key, $item) = each($smarty->blockvars[$l])) {
			$repeat = true;
			$item['date'] = setDate($item['date']);
			$smarty->assign($params['name'], $item);
		}
		else {
			$repeat = false;
			reset($smarty->blockvars[$l]);
		}
		
		if(!is_null($content)) print $content;
	
		//
		if(!$repeat) $smarty->blockvars[$l] = array();
	}